﻿using SrBBSPro.Services;
using SrBBSPro.Services.Messaging;
using System;
using SrBBSPro.BaseClasses;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SrBBSPro.Controllers
{
    public class HomeController : BaseController
    {
        // GET: Home
        [AllowAnonymous]
        public ActionResult Index()
        {
            //获取第一页的三十条数据
            var request = new GetPagePostsRequest(1, 30);
            var response = new PostService().GetPagePostsByFilter(request);
            return View(response);
        }
        //月雷锋榜Top12
        [AllowAnonymous]
        public PartialViewResult LoadContributionTopTwelve()
        {
            var response = new ContributionService().GetTopTwelve();
            return PartialView("_Contribution", response);
        }

        public ActionResult RedirectToPage()
        {
            long Id = Convert.ToInt64(Request.QueryString["Id"]);
            string no = Request.QueryString["no"];
            string ctr = Request.QueryString["ctr"];
            string view = Request.QueryString["view"];
            string kind = Request.QueryString["kind"];
            EntId = Id;
            EntNo = no;
            EntKind = kind;
            if (string.IsNullOrEmpty(ctr) || string.IsNullOrEmpty(view))
            {
                return RedirectToAction("/");
            }
            return RedirectToAction(view, ctr);
        }
    }
}